<template>
	<view>
		<!-- 收款账号输入框 -->
		<view
			style="width: 703rpx;height: 250rpx;background-color: #FFFFFF;margin: auto;border-radius: 20rpx; padding-top: 10rpx;margin-top: 20rpx;"
		>
			<input
				class="uni-input"
				v-model="pay_bank"
				placeholder="请输入收款的支付宝账号"
				placeholder-style="font-size: 24rpx;color: #999999"
				style="width: 620rpx;height: 80rpx;background-color: #F5F5F5;margin-left: 20rpx;margin-top: 20rpx;  padding-left: 20rpx;"
			/>
			<input
				style="width: 620rpx;height: 80rpx;background-color: #F5F5F5;margin-left: 20rpx;  padding-left: 20rpx;margin-top: 30rpx;"
				v-model="xinmign"
				placeholder="请输入姓名"
				placeholder-style="font-size: 24rpx;color: #999999"
			/>
		</view>
		<view
			style="width: 700rpx;margin: auto;height: 250rpx;background-color: #FFFFFF;margin-top: 20rpx;border-radius: 10rpx;padding-top: 20rpx;display: flex;"
		>
			<view >
				<p style="color: #999999;font-size: 24rpx;height: 40rpx;line-height: 40rpx;margin-left: 10rpx;">
					请输入收款码
				</p>
				<u-upload
					width="160rpx"
					height="160rpx"
					:action="action"
					:auto-upload="true"
					max-count="1"
					@on-success="success1"
				></u-upload>
			</view>
			<p
				style="width: 700rpx;height: 200rpx;line-height: 200rpx;font-weight: bold;text-align: center;"
			>
				实际到账
				<span style="color: #ff0000;">{{ shiji_money }}</span>
				元
			</p>
		</view>

		<!-- 金额输入框 -->
		<view
			style="width: 703rpx;height: 386rpx;background-color: #FFFFFF;margin: 0 auto;margin-top: 20rpx;border-radius: 20rpx;
		display: flex;flex-direction: column;align-items: center;"
		>
			<view   style="width: 662rpx;margin-top: 36rpx; display: flex;">
				<view
					
					style="font-size: 32rpx;font-weight: bold;color: #333333;"
				>
					￥
				</view>
				<input
					class="uni-input"
					v-model="money1"
					style="width: 502rpx; height: 34rpx;margin-left: 30rpx;"
				/>
				<view
					style="width: 116rpx;height: 44rpx;background-color: #FE3548;text-align: center;
					font-size: 24rpx;color: #FFFFFF;font-weight: bold;line-height: 44rpx;border-radius: 10rpx;"
					@click="quanbu"
				>
					全部
				</view>
			</view>

			<view
				style="width: 662rpx;height: 1px;background-color: #F5F5F5;margin-top: 12rpx;"
			></view>

			<view
				style="font-size: 18rpx;color: #999999;align-self: flex-start; margin-left: 20rpx;margin-top: 20rpx;"
			>
				<view>当前余额{{ money }}元，</view>
				<view>
					三个工作日内到账；1-100元提一次收1元手续费；100以上1%
				</view>
			</view>

			<view
				@click="withdraw"
				style="width: 548rpx;height: 88rpx;background-color: #FE3548;border-radius: 20rpx;margin-top: 42rpx;
			font-size: 32rpx;color: #FFFFFF;font-weight: bold;text-align: center;line-height: 88rpx;"
			>
				申请提现
			</view>
		</view>
		<u-popup v-model="show" mode="center" width="500rpx" height="260rpx" closeable>
				<view style="width: 450rpx;height: 60rpx;margin-top: 90rpx;margin-left: 25rpx; text-align: center;font-size: 35rpx;font-weight: 800;">
					提现信息是否无误
				</view>
				<view style="width: 100%;height: 60rpx;margin-top: 50rpx;display: flex;">
					<view style="width: 50%;height: 60rpx;text-align: center;line-height: 60rpx;border-right: 1rpx solid #cccccc;" @click="qu_xiao">取消</view>
					<view style="width: 50%;height: 60rpx;text-align: center;line-height: 60rpx;" @click="ti_xian">确定</view>
				</view>
				
		</u-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			show: false,
			xinmign: '',
			bank: '',
			money: '',
			money1: '',
			shiji_money: 0,
			pay_bank: '',
			url: '',
			action: 'https://jizhuan6688.com/api/upload/upload'
			// money: '',
			// money: '',
		};
	},
	onLoad(e) {
		this.usrWdrl();
	},
	methods: {
		async ti_xian() {
			this.show = false
			
			let obj = {
				uid: uni.getStorageSync('uid'),
				bank: this.pay_bank,
				money: this.money1,
				name: this.xinmign,
				bank_code: this.url
			};
			const res = await this.$u.post('api/user/user_deposit', obj, {});
			console.log('res >>  ', res);
			uni.navigateTo({
				url: './me_yue',
			});
			uni.$showMsg(res.msg);
			
		},
		qu_xiao() {
			this.show = false
		},
		success1(index, lists) {
			console.log('index  :>> ', index);
			console.log('lists  :>> ', lists);
			this.url = index.url;
			console.log('this.url  :>> ', this.url);
		},
		quanbu() {
			this.money1 = this.money;
			if (this.money <= 100 && this.money >= 1) {
				this.shiji_money = this.money - 1;
			} else if (this.money > 100) {
				this.shiji_money = this.money - this.money * 0.01;
			}
		},
		async usrWdrl() {
			let obj = {
				uid: uni.getStorageSync('uid')
			};
			const res = await this.$u.post('api/user/withdrawal', obj, {});
			console.log('res >>  ', res);
			if (!res.code) return uni.$showMsg();
			this.money = res.data.money;
			this.pay_bank = res.data.pay_bank;
		},
		async withdraw() {
			if (!this.pay_bank) return uni.$showMsg('请填写支付宝账号!');
			if (!this.money1) return uni.$showMsg('请填写提现的金额!');
			if (!this.xinmign) return uni.$showMsg('请填写姓名!');
			if (!this.url) return uni.$showMsg('请上传图片!');
			//if (!this.url) return uni.$showMsg('请上传二维码!');
			this.show = true
		}
	}
};
</script>

<style>
page {
	background-color: #fcfaff;
}
</style>
